package com.example.demo.test.selenium;

import org.apache.commons.lang3.SystemUtils;
import org.openqa.selenium.PageLoadStrategy;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;


public class Chrome {

    public static WebDriver getOneDriver() {
        ChromeOptions chromeOptions = new ChromeOptions();
        chromeOptions.setAcceptInsecureCerts(true);
        chromeOptions.setPageLoadStrategy(PageLoadStrategy.EAGER);
        chromeOptions.addArguments("headless");//无界面参数
        //针对linux环境设置
        if (SystemUtils.IS_OS_LINUX) {
            System.setProperty("webdriver.chrome.driver", "/home/work/driver/chromedriver");
            chromeOptions.addArguments("no-sandbox");//禁用沙盒
        } else if (SystemUtils.IS_OS_WINDOWS) {
            System.setProperty("webdriver.chrome.driver", "D:\\soft\\devtool\\driver\\chromedriver.exe");
        }
        return new ChromeDriver(chromeOptions);
    }


}
